<%@page contentType="text/html"%>
<%@page pageEncoding="UTF-8"%>

<%-- Uncomment below lines to add portlet taglibs to jsp--%>
<%@ page import="javax.portlet.*"%>
<%@ page import="com.jefe.service.service.MessageTblLocalServiceUtil"%>
<%@ page import="com.jefe.service.model.*" %>
<%@ page import="com.jefe.service.service.*" %>
<%@ taglib uri="http://java.sun.com/portlet_2_0" prefix="portlet"%>

<portlet:defineObjects />
<%
PortletPreferences prefs = renderRequest.getPreferences();
PortletURL actionURL = renderResponse.createActionURL();
%>
<%-- Display Error or Success Messages--%>
<%
String error = renderRequest.getParameter("error");
String success = renderRequest.getParameter("success");

if(error!=null){ //if there are any error messages display here
    out.println("<div class=\"portlet-msg-error\">"+error.replace("+", " ")+"</div>");
}
if(success!=null){ // if there are any success messages display here
    out.println("<div class=\"portlet-msg-success\">"+success.replace("+", " ")+"</div>");
}
%>
<%-- Display Step 1--%>
<%
actionURL.setParameter("form", "select");
%>
<div class="portlet-font" style="font-size: large">Choose a Display Message</div>
<form action="<%=actionURL.toString()%>" method="post">
    <table border="0">
        <tr>
            <td>Select a message to display</td>
            <td>:</td>
            <td>
                <select name="choice">
                    <option value="0">Jefe Default</option>
                    
                <%
                    int number = MessageTblLocalServiceUtil.getMessageTblsCount();
                    System.out.println("number:"+number);
                    for( int i = 1; i<number+1; i++){
                        out.println("<option value='"+i+"'>"+MessageTblLocalServiceUtil.getMessageTbl(i).getShortName()+"</option>");
                    }
                %>
                </select>
            </td>
            <td><input type="submit" value="Select" /></td>
            
    </tr>
    </table>
</form>
<hr />
<br />
<%--Display step 2--%>
<%
actionURL.setParameter("form", "add");
%>
<div class="portlet-font" style="font-size: large">Add a new Message</div>
<form action="<%=actionURL.toString() %>" method="POST">
    <table border="0" cellpadding="3">
        <tr>
            <td>Short Name</td>
            <td>:</td>
            <td><input type="text" name="shortName" value="" /></td>
        </tr>
        <tr><td></td><td></td><td><div class="portlet-font" style="font-size: xx-small">This will be used to represent the message in the above dropdown menu.</div></td></tr>
        <tr>
            <td>Heading</td>
            <td>:</td>
            <td><input title="Input a Heading" name="heading" type="text" size="80%" /></td>
        </tr>
        <tr>
            <td>Message</td>
            <td>:</td>
            <td><textarea cols="100%" rows="8" name="message" title="Input a display message"  ></textarea></td>
        </tr>
        <tr>
            <td>Image URL</td>
            <td>:</td>
            <td><input title="Image URL from Image Gallery" name="image" type="text" size="80%" /></td>
        </tr>
        <tr><td></td><td></td><td><div class="portlet-font" style="font-size: xx-small">First Upload the Image to the Image Gallery Portlet and get the URL of the image and input here.</div></td></tr>
        <tr>
            <td></td>
            <td></td>
            <td><input type="submit" value="Add"/><input type="reset" value="Reset"/></td>
        </tr>
    </table>
</form>